<?php
/**
 * Dwz 表格数据插件
 *
 * @author maomao.thx@gmail.com
 * @copyright Copyright (c) 2009 Green Shore (http://www.iwgame.com)
 * @version $Id: DwzTable.php 1104 2011-12-21 08:00:36Z mmxie $
 */
class IG_Data_Plugin_DwzTable extends IG_Data_Plugin
{
    protected $_columns;
    protected $_attrs = array();
    protected $_checkbox;
    protected $_target;

    /**
     * Unused
     * @param array $columns
     */
    public function setTitles(array $columns)
    {
        $this->_columns = $columns;
        return $this;
    }

    public function setColumns(array $columns)
    {
        $this->_columns = $columns;
        return $this;
    }

    public function setAttrs(array $attrs)
    {
        $this->_attrs = $attrs;
        return $this;
    }

    public function setCheckbox(array $name)
    {
        $this->_checkbox = $name;
        return $this;
    }

    public function setTarget($target)
    {
        $this->_target = $target;
        return $this;
    }

    public function after()
    {
        $rows = $this->getSource()->getRows();
        echo '<div class="pageContent">';
        echo $this->getView()->dwzTable($this->_columns, $rows,
                                        $this->_attrs, $this->_checkbox,
                                        $this->_target)->__toString();

        if ($this->getSource()->hasPaginator()) {
            $paginator = $this->getSource()->getPaginator();
            echo $this->getView()
                      ->paginationControl($paginator,
                                           'Sliding',
                                           array('DwzPage.phtml', 'system'),
                                           array(
                                               'pageRange' => $paginator->getPageRange(),
                                               'params' => $this->getSource()->getParams()
                                           ));
        }

        echo '<div>';
    }
}